package edu.rit.teamrocket.view;

import java.awt.*;

import javax.swing.*;

import edu.rit.teamrocket.controller.FoodController;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class DietManager extends JFrame
{
	private JPanel panel1, panel2, panel3, panel4;
	private JButton newEntry, dailyCalender, addFood, addRecipe, saveDailyLog, saveFoodCollection, reset;
	private TextArea text;
	private FoodController controller;
	private JFrame context;

	public DietManager()
	{
		super("Diet Manager");
		
		controller = new FoodController();
		context = this;
		
		text = new TextArea(10, 50);
		newEntry = new JButton("New Entry");
		newEntry.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e)
			{
				new NewEntry(context);
				context.setVisible(false);
			}
		});


		dailyCalender = new JButton("Open");
		dailyCalender.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e)
			{
				System.out.println("blah");
			}
		});

		addFood = new JButton("Add Food");
		addFood.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e)
			{
				new AddFood();
			}
		});

		addRecipe = new JButton("Add Recipe");
		addRecipe.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e)
			{
				new AddRecipe();
			}
		});

		saveDailyLog = new JButton("Save Daily Log");
		saveDailyLog.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e)
			{
				System.out.println("You clicked the button");
			}
		});

		saveFoodCollection = new JButton("Save Food Collection");
		saveFoodCollection.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e)
			{
				System.out.println("You clicked the button");
			}
		});

		reset = new JButton("Reset");
		reset.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e)
			{
				System.out.println("You clicked the button");
			}
		});

		panel1 = new JPanel();
		this.add(panel1, BorderLayout.EAST);
		panel1.add(text);

		panel2 = new JPanel();
		this.add(panel2, BorderLayout.SOUTH);
		panel2.add(saveDailyLog);
		saveDailyLog.setPreferredSize(new Dimension(155, 20));
		panel2.add(saveFoodCollection);
		saveFoodCollection.setPreferredSize(new Dimension(155, 20));
		panel2.add(reset);
		reset.setPreferredSize(new Dimension(155, 20));

		panel3 = new JPanel();
		panel3.setLayout(new GridLayout(0,1,10,5));
		this.add(panel3, BorderLayout.WEST);
		panel3.add(newEntry);
		//newEntry.setPreferredSize(new Dimension(20, 10));
		panel3.add(dailyCalender);
		//dailyCalender.setPreferredSize(new Dimension(100, 10));
		panel3.add(addFood);
		//addFood.setPreferredSize(new Dimension(100, 10));
		panel3.add(addRecipe);
		//addRecipe.setPreferredSize(new Dimension(100, 10));

		panel4 = new JPanel();
		this.add(panel4, BorderLayout.NORTH);

		this.setVisible(true);
		this.pack();
		this.setResizable(false);

	}

	public static void main(String args[])
	{
		new DietManager();
	}


}
